package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 25397
 * Date: 2022-03-29
 * Time: 18:29
 */
public class Demo18 {
    private static Object locker=new Object();

    public static void main(String[] args) throws InterruptedException {
        Thread t1=new Thread(()->{
           //进行wait
            synchronized (locker){
                System.out.println("wait 之前");
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("wait之后");
            }
        });
        t1.start();

        Thread.sleep(3000);

        Thread t2=new Thread(()->{
            //进行notify
            synchronized (locker){
                System.out.println("notify之前");
                locker.notify();
                System.out.println("notify之后");
            }
        });
        t2.start();
    }
}
